home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / B-C / C++ FAQ Reference 1.0 / C++ FAQ Reference 1.0.rsrc / TEXT_1432.txt < prev    next >
Encoding:
Text File  |  1993-06-30  |  1.1 KB  |  14 lines

  1. The three performance hits are enumerated in the previous question:
  2.  * By itself, an extra layer of indirection is small potatoes.
  3.  * Freestore allocations can be a big problem (standard malloc's performance
  4.    degrades with more small freestore allocations; OO s/w can easily become
  5.    'freestore bound' unless you're careful).
  6.  * Extra dynamic binding comes from having a ptr rather than an object.
  7.    Whenever the C++ compiler can know an object's *exact* class, virtual fn
  8.    calls can be *statically* bound, which allows inlining.  Inlining allows
  9.    zillions (would you believe half a dozen :-) optimization opportunities
  10.    such as procedural integration, register lifetime issues, etc.  The C++
  11.    compiler can know an object's exact class in three circumstances: local
  12.    variables, global/static variables, and fully-contained subobjects.
  13.  
  14. Thus fully-contained subobjects allow significant optimizations that wouldn't be possible under the 'subobjects-by-ptr' approach (this is the main reason that languages which enforce reference-semantics have 'inherent' performance problems).